package cn.binarywang.tools.generator.util;

import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * 日期工具类, 继承org.apache.commons.lang.time.DateUtils类
 * @author liuf
 * @version 2020-3-15
 */
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {

    public static final String format_yyyyMMddHHmmssSSS = "yyyy-MM-dd HH:mm:ss.SSS";

    public static final String format_yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss";
    public static final String YYYYMMDD = "yyyy-MM-dd";

    public static final String YYYYMMDD_ZH = "yyyy年MM月dd日";

    public static final int FIRST_DAY_OF_WEEK = Calendar.MONDAY; // 中国周一是一周的第一天


    private static String[] parsePatterns = {"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm",
        "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyyMMdd", "yyyyMMdd HH:mm:ss", "yyyyMMdd HH:mm"};

    /**
     * 得到当前日期字符串 格式（yyyy-MM-dd）
     */
    public static String getDate() {
        return getDate("yyyy-MM-dd");
    }

    /**
     * 得到当前日期字符串 格式（yyyy-MM-dd） pattern可以为："yyyy-MM-dd" "HH:mm:ss" "E"
     */
    public static String getDate(String pattern) {
        return DateFormatUtils.format(new Date(), pattern);
    }

    /**
     * 得到当前日期字符串 格式（yyyy-MM-dd） pattern可以为："yyyy-MM-dd" "HH:mm:ss" "E"
     */
    public static String getDate(Date Date, String pattern) {
        return DateFormatUtils.format(Date, pattern);
    }


    /**
     * 得到日期字符串 默认格式（yyyy-MM-dd） pattern可以为："yyyy-MM-dd" "HH:mm:ss" "E"
     */
    public static String formatDate(Date date, Object... pattern) {
        String formatDate = null;
        if (pattern != null && pattern.length > 0) {
            formatDate = DateFormatUtils.format(date, pattern[0].toString());
        } else {
            formatDate = DateFormatUtils.format(date, "yyyy-MM-dd");
        }
        return formatDate;
    }

    /**
     * 用于mongodb 日期
     * 得到日期字符串 pattern可以为："yyyy-MM-dd"
     */
    public static String formatDate(String date, String pattern) {
        String dateString = null;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
            SimpleDateFormat sdfDte = new SimpleDateFormat(pattern);
            dateString = sdfDte.format(sdf.parse(date));
        } catch (ParseException e) {

        }
        return dateString;
    }

    /**
     * 用于将ES日期转为date
     */
    public static Date formatESDate(String dateStr) {
        Date date = null;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String mailInfluenceDateStr = dateStr.replaceAll("T", " ");
            date = sdf.parse(mailInfluenceDateStr);
        } catch (ParseException e) {

        }
        return date;
    }

    /**
     * 用于将ES日期转为date
     */
    public static String formatESToString(String dateStr, String pattern) {
        String date = null;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String mailInfluenceDateStr = dateStr.replaceAll("T", " ");
            date = DateUtils.formatDate(sdf.parse(mailInfluenceDateStr), pattern);
        } catch (ParseException e) {

        }
        return date;
    }

    /**
     * 得到当前时间字符串 格式（HH:mm:ss）
     */
    public static String getTime() {
        return formatDate(new Date(), "HH:mm:ss");
    }

    /**
     * 得到当前日期和时间字符串 格式（yyyy-MM-dd HH:mm:ss）
     */
    public static String getDateTime() {
        return formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
    }

    /**
     * 得到当前年份字符串 格式（yyyy）
     */
    public static String getYear() {
        return formatDate(new Date(), "yyyy");
    }

    /**
     * 得到当前月份字符串 格式（MM）
     */
    public static String getMonth() {
        return formatDate(new Date(), "MM");
    }
    /**
     * 得到当小时字符串 格式（dd）
     */
    public static String getHours() {
        return formatDate(new Date(), "HH");
    }

    /**
     * 得到当天字符串 格式（dd）
     */
    public static String getDay() {
        return formatDate(new Date(), "dd");
    }

    /**
     * 得到当前星期字符串 格式（E）星期几
     */
    public static String getWeek() {
        return formatDate(new Date(), "E");
    }

    /**
     * 日期型字符串转化为日期 格式
     * { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm",
     * "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm" }
     */
    public static Date parseDate(Object str) {
        if (str == null) {
            return null;
        }
        try {
            return parseDate(str.toString(), parsePatterns);
        } catch (ParseException e) {
            return null;
        }
    }

    /**
     * 随机时间
     * @return
     */
    public static Date randomDate() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(1990, 1, 1);
        long earlierDate = calendar.getTime().getTime();
        calendar.set(2021, 3, 1);
        long laterDate = calendar.getTime().getTime();

        long chosenDate = RandomUtils.nextLong(earlierDate, laterDate);

        return new Date(chosenDate);
    }

    /**
     * 获取过去的天数
     *
     * @param date
     * @return
     */
    public static long pastDays(Date date) {
        long t = new Date().getTime() - date.getTime();
        return t / (24 * 60 * 60 * 1000);
    }

    /**
     * 过去的分钟
     *
     * @param date1
     * @param date2
     * @return
     */
    public static long pastMinutes(Date date1, Date date2) {
        long t = date1.getTime() - date2.getTime();
        return t / (60 * 1000);
    }

    /**
     * 得到几天前的日期
     *
     * @param d
     * @param day
     * @return
     */
    public static Date getDateBefore(Date d, int day) {
        Calendar now = Calendar.getInstance();
        now.setTime(d);
        now.set(Calendar.DATE, now.get(Calendar.DATE) - day);
        return now.getTime();
    }

    /**
     * 得到每一天日期
     *
     * @param beginDay
     * @param EndDay
     * @param type     1:yyyy-MM-dd  2：MM月dd日
     * @return
     */
    public static String getEveryDate(Date beginDay, Date EndDay, int type) {
        String strDate = null;
        SimpleDateFormat sdf = null;
        if (type == 1) {
            sdf = new SimpleDateFormat("yyyy-MM-dd");
        } else {
            sdf = new SimpleDateFormat("MM月dd日");
        }
        long t = (EndDay.getTime() - beginDay.getTime()) / (24 * 60 * 60 * 1000);            //相差天数
        for (int i = (int) t; i >= 0; i--) {
            if (strDate == null) {
                strDate = sdf.format(getDateBefore(EndDay, i));
            } else {
                strDate += "," + sdf.format(getDateBefore(EndDay, i));
            }
        }
        return strDate;
    }

    /**
     * 两个日期相减，获取两者之间的时间间隔（秒）
     *
     * @param date1 被减时间
     * @param date2 减时间
     * @return 秒数
     */
    public static int subSecond(Date date1, Date date2) {
        //实例化Calendar
        Calendar calendar = Calendar.getInstance();
        //获取第一个日期对应的毫秒数
        calendar.setTime(date1);
        long timethis = calendar.getTimeInMillis();
        //获取第二个日期对应的毫秒数
        calendar.setTime(date2);
        long timeend = calendar.getTimeInMillis();
        //计算两个日期的间隔时间
        long theday = (timethis - timeend) / 1000;
        return (int) theday;
    }

    /**
     * 当前时间多少秒之前时间
     * @param date
     * @param timeInMillis
     * @return
     */
    public static String getDateTimeBefore(Date date, Long timeInMillis) {
        //实例化Calendar
        Calendar calendar = Calendar.getInstance();
        //获取第一个日期对应的毫秒数
        calendar.setTime(date);
        long timethis = calendar.getTimeInMillis() - timeInMillis*1000;
        Date start = new Date(timethis);
        return formatDate(start,"yyyy-MM-dd HH:mm:ss") ;

    }

    /**
     * 当前时间多少秒之前时间
     * @param date
     * @param timeInMillis
     * @return
     */
    public static Date getDateTimeBeforeByHours(Date date, Long Hours) {
        //实例化Calendar
        Calendar calendar = Calendar.getInstance();
        long timethis = calendar.getTimeInMillis() - Hours*60*60*1000;
        calendar.setTimeInMillis(timethis);
        return new Date(timethis);
    }
    /**
     * 将时间改为带东八区的字符串（用于存储到es中）
     *
     * @param date
     * @return
     */
    public static String getDateGMTParse(Date date) {
        String pattern = "yyyy-MM-dd\'T\'HH:mm:ss.SSS+0800";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        String dateStr = simpleDateFormat.format(date);
        return dateStr;
    }

    /**
     * 将string转为date
     */
    public static Date getDateByStr(String dateStr, String pattern) {
        SimpleDateFormat formatter = new SimpleDateFormat(pattern);
        try {
            Date date = formatter.parse(dateStr);
            return date;
        } catch (ParseException e) {
            return null;
        }
    }


    /**
     * 获取 年月日 时 分 秒 当前时间毫秒数
     *
     * @param data
     * @return
     */
    public static Calendar getCalendar(String data) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d = null;
        Calendar calendar = null;
        try {
            d = sdf.parse(data);
            calendar = Calendar.getInstance();
            calendar.setTime(d);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return calendar;
    }

    /**
     * Date字符串转ZonedDateTime
     *
     * @param dataTime 字符串时间
     * @return ZonedDateTime
     */
    public static ZonedDateTime dateTimeStrToZoned(String dateTime) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(parsePatterns[1]);
        LocalDateTime localDateTime = LocalDateTime.parse(dateTime, formatter);
        return ZonedDateTime.of(localDateTime, ZoneId.systemDefault());
    }

    /**
     * Date字符串转ZonedDateTime（time 和 amOrPm 不能同时为null
     * time : 自定义时间部分； amOrPm : 0  上午-00:00:00; 1  下午-23:59:59）
     *
     * @param date   日期部分
     * @param time   时间部分
     * @param amOrPm 0 00:00:00/ 1 23:59:59
     * @return ZonedDateTime
     */
    public static ZonedDateTime dateTimeStrToZoned(String date, String time, Integer amOrPm) {
        String blankChar = " ";
        String dateTime = new String();
        if ((StringUtils.isEmpty(time) && amOrPm == null) ||
            (!StringUtils.isEmpty(time) && amOrPm != null)) {
            return null;
        } else if (!StringUtils.isEmpty(time)) {
            dateTime = date + blankChar + time;
        } else if (amOrPm != null && amOrPm.equals(0)) {
            dateTime = date + blankChar + "00:00:00";
        } else if (amOrPm != null && amOrPm.equals(1)) {
            dateTime = date + blankChar + "23:59:59";
        }
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(parsePatterns[1]);
        LocalDateTime localDateTime = LocalDateTime.parse(dateTime, formatter);
        return ZonedDateTime.of(localDateTime, ZoneId.systemDefault());
    }

    /**
     * date2比date1多的天数
     *
     * @param date1
     * @param date2
     * @return
     */
    public static int differentDays(Date date1, Date date2) {
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);

        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(date2);
        int day1 = cal1.get(Calendar.DAY_OF_YEAR);
        int day2 = cal2.get(Calendar.DAY_OF_YEAR);

        int year1 = cal1.get(Calendar.YEAR);
        int year2 = cal2.get(Calendar.YEAR);
        if (year1 != year2) {
            //不同年
            int timeDistance = 0;
            for (int i = year1; i < year2; i++) {
                if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
                    //闰年
                    timeDistance += 366;
                } else {
                    //不是闰年
                    timeDistance += 365;
                }
            }
            return timeDistance + (day2 - day1);
        } else {
            //同一年
            return day2 - day1;
        }
    }
    /**
     * 取得季度已过天数
     *
     * @param date
     * @return
     */
    public static int getPassDayOfSeason(Date date) {
        int day = 0;

        Date[] seasonDates = getSeasonDate(date);

        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int month = c.get(Calendar.MONTH);

        if (month == Calendar.JANUARY || month == Calendar.APRIL
            || month == Calendar.JULY || month == Calendar.OCTOBER) {// 季度第一个月
            day = getPassDayOfMonth(seasonDates[0]);
        } else if (month == Calendar.FEBRUARY || month == Calendar.MAY
            || month == Calendar.AUGUST || month == Calendar.NOVEMBER) {// 季度第二个月
            day = getDayOfMonth(seasonDates[0])
                + getPassDayOfMonth(seasonDates[1]);
        } else if (month == Calendar.MARCH || month == Calendar.JUNE
            || month == Calendar.SEPTEMBER || month == Calendar.DECEMBER) {// 季度第三个月
            day = getDayOfMonth(seasonDates[0]) + getDayOfMonth(seasonDates[1])
                + getPassDayOfMonth(seasonDates[2]);
        }
        return day;
    }

    /**
     * 取得日期：年
     *
     * @param date
     * @return
     */
    public static int getYear(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int year = c.get(Calendar.YEAR);
        return year;
    }
    /**
     * 取得日期：年
     *
     * @param date
     * @return
     */
    public static int getDay(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int da = c.get(Calendar.DAY_OF_YEAR);
        return da;
    }


    /**
     * 取得日期：年
     *
     * @param date
     * @return
     */
    public static int getMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int month = c.get(Calendar.MONTH);
        return month + 1;
    }

    /**
     * 取得日期：当月第几天
     *
     * @param date
     * @return
     */
    public static int getDayOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int da = c.get(Calendar.DAY_OF_MONTH);
        return da;
    }

    /**
     * 取得当天日期是周几
     *
     * @param date
     * @return
     */
    public static int getWeekDay(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int week_of_year = c.get(Calendar.DAY_OF_WEEK);
        return week_of_year - 1;
    }

    /**
     * 取得当月的第几周
     *
     * @param date
     * @return
     */
    public static int getWeekOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int week_of_month = c.get(Calendar.WEEK_OF_MONTH);
        return week_of_month;
    }
    /**
     * 取得一年的第几周
     *
     * @param date
     * @return
     */
    public static int getWeekOfYear(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int week_of_year = c.get(Calendar.WEEK_OF_YEAR);
        return week_of_year;
    }

    /**
     * getWeekBeginAndEndDate
     *
     * @param date
     * @param pattern
     * @return
     */
    public static String getWeekBeginAndEndDate(Date date, String pattern) {
        Date monday = getMondayOfWeek(date);
        Date sunday = getSundayOfWeek(date);
        return formatDate(monday, pattern) + " - "
            + formatDate(sunday, pattern);
    }
    /**
     * 获取星期几
     *
     * @param date
     * @return
     */
    public static int getWeek(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int week = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (week == 0) {
            week = 7;
        }
        return week;
    }


    /**
     * 根据日期取得对应周周一日期
     *
     * @param date
     * @return
     */
    public static Date getMondayOfWeek(Date date) {
        Calendar monday = Calendar.getInstance();
        monday.setTime(date);
        monday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
        monday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        return monday.getTime();
    }

    /**
     * 根据日期取得对应周周日日期
     *
     * @param date
     * @return
     */
    public static Date getSundayOfWeek(Date date) {
        Calendar sunday = Calendar.getInstance();
        sunday.setTime(date);
        sunday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
        sunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
        return sunday.getTime();
    }

    /**
     * 取得月的剩余天数
     *
     * @param date
     * @return
     */
    public static int getRemainDayOfMonth(Date date) {
        int dayOfMonth = getDayOfMonth(date);
        int day = getPassDayOfMonth(date);
        return dayOfMonth - day;
    }

    /**
     * 取得月已经过的天数
     *
     * @param date
     * @return
     */
    public static int getPassDayOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c.get(Calendar.DAY_OF_MONTH);
    }


    /**
     * 取得月第一天
     *
     * @param date
     * @return
     */
    public static Date getFirstDateOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH));
        return c.getTime();
    }

    /**
     * 取得月最后一天
     *
     * @param date
     * @return
     */
    public static Date getLastDateOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
        return c.getTime();
    }

    /**
     * 取得季度第一天
     *
     * @param date
     * @return
     */
    public static Date getFirstDateOfSeason(Date date) {
        return getFirstDateOfMonth(getSeasonDate(date)[0]);
    }

    /**
     * 取得季度最后一天
     *
     * @param date
     * @return
     */
    public static Date getLastDateOfSeason(Date date) {
        return getLastDateOfMonth(getSeasonDate(date)[2]);
    }

    /**
     * 取得季度天数
     *
     * @param date
     * @return
     */
    public static int getDayOfSeason(Date date) {
        int day = 0;
        Date[] seasonDates = getSeasonDate(date);
        for (Date date2 : seasonDates) {
            day += getDayOfMonth(date2);
        }
        return day;
    }

    /**
     * 取得季度剩余天数
     *
     * @param date
     * @return
     */
    public static int getRemainDayOfSeason(Date date) {
        return getDayOfSeason(date) - getPassDayOfSeason(date);
    }

    /**
     * 取得季度月
     *
     * @param date
     * @return
     */
    public static Date[] getSeasonDate(Date date) {
        Date[] season = new Date[3];

        Calendar c = Calendar.getInstance();
        c.setTime(date);

        int nSeason = getSeason(date);
        if (nSeason == 1) {// 第一季度
            c.set(Calendar.MONTH, Calendar.JANUARY);
            season[0] = c.getTime();
            c.set(Calendar.MONTH, Calendar.FEBRUARY);
            season[1] = c.getTime();
            c.set(Calendar.MONTH, Calendar.MARCH);
            season[2] = c.getTime();
        } else if (nSeason == 2) {// 第二季度
            c.set(Calendar.MONTH, Calendar.APRIL);
            season[0] = c.getTime();
            c.set(Calendar.MONTH, Calendar.MAY);
            season[1] = c.getTime();
            c.set(Calendar.MONTH, Calendar.JUNE);
            season[2] = c.getTime();
        } else if (nSeason == 3) {// 第三季度
            c.set(Calendar.MONTH, Calendar.JULY);
            season[0] = c.getTime();
            c.set(Calendar.MONTH, Calendar.AUGUST);
            season[1] = c.getTime();
            c.set(Calendar.MONTH, Calendar.SEPTEMBER);
            season[2] = c.getTime();
        } else if (nSeason == 4) {// 第四季度
            c.set(Calendar.MONTH, Calendar.OCTOBER);
            season[0] = c.getTime();
            c.set(Calendar.MONTH, Calendar.NOVEMBER);
            season[1] = c.getTime();
            c.set(Calendar.MONTH, Calendar.DECEMBER);
            season[2] = c.getTime();
        }
        return season;
    }

    /**
     *
     * 1 第一季度 2 第二季度 3 第三季度 4 第四季度
     *
     * @param date
     * @return
     */
    public static int getSeason(Date date) {

        int season = 0;

        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int month = c.get(Calendar.MONTH);
        switch (month) {
            case Calendar.JANUARY:
            case Calendar.FEBRUARY:
            case Calendar.MARCH:
                season = 1;
                break;
            case Calendar.APRIL:
            case Calendar.MAY:
            case Calendar.JUNE:
                season = 2;
                break;
            case Calendar.JULY:
            case Calendar.AUGUST:
            case Calendar.SEPTEMBER:
                season = 3;
                break;
            case Calendar.OCTOBER:
            case Calendar.NOVEMBER:
            case Calendar.DECEMBER:
                season = 4;
                break;
            default:
                break;
        }
        return season;
    }


    /**
     * 根据给定的时间得到到目前为止过了多少秒
     */
    public static long getOverTime(String time) {

        try {
            Instant timeInstant = DateUtils.parseDate(time).toInstant();
            Instant now = Instant.now();

            return Math.abs(Duration.between(timeInstant, now).getSeconds());
        } catch (Exception e) {
            return 0L;
        }

    }


    public static String  getEventTime ( Date date) {
        String str[] ={"event_time_yyyyMMddhhmmss","event_time_yyyyMMddhhmm","event_time_yyyyMMddhh","event_time_yyyyMMdd","event_time_yyyyqq","event_time_yyyyMM","event_time_yyyyww","event_time_yyyyddd","event_time_yyyy","event_time_q","event_time_month","event_time_d","event_time_h","event_time_minute","event_time_s","event_time_dayinweek","event_time_dayinyear","event_time_weekinmonth","event_time_weekinyear"};
        String event_time = "";
        for (String s :str) {
            Object text = "";
            if (s.contains("event_time_")) {
                String key = s.split("event_time_")[1];
                if (key.contains("yyyy")) {
                    if (key.contains("yyyyqq")) {
                        text = getYear(date)+""+getSeason(date);
                    } else {
                        text = DateUtils.formatDate(date,key);
                    }

                } else {
                    switch (key) {
                        case "q":text =  getSeason(date); break;
                        case "month":text =  getMonth(date); break;
                        case "h":text = formatDate(date, "hh"); break;
                        case "s":text =formatDate (date, "ss"); break;
                        case "minute":text = formatDate(date, "mm"); break;
                        case "d":text =  formatDate(date, "d"); break;
                        case "dayinweek":text =  getWeekDay(date); break;
                        case "dayinyear":text =  getYear(date); break;
                        case "weekinmonth":text =  getWeekOfMonth(date); break;
                        case "weekinyear":text =  getWeekOfYear(date); break;
                        default:
                            break;
                    }
                }
                if (StringUtils.isBlank(event_time)){
                    event_time = text.toString();
                } else {
                    event_time +=","+ text.toString();
                }
                System.out.println(key);
            }

        }
        return  event_time;
    }

}
